home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 014 / dex / dex.lo < prev    next >
Text File  |  1995-03-17  |  11KB  |  619 lines

  1. /* # include "stdio.h"   **** WARNING **** hand modified, MANX C does not
  2.    like having stdio.h included twice!! ***/
  3.  
  4. # define U(x) x
  5. # define NLSTATE yyprevious=YYNEWLINE
  6. # define BEGIN yybgin = yysvec + 1 +
  7. # define INITIAL 0
  8. # define YYLERR yysvec
  9. # define YYSTATE (yyestate-yysvec-1)
  10. # define YYOPTIM 1
  11. # define YYLMAX 200
  12. # define output(c) putc(c,yyout)
  13. # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  14. # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
  15. # define yymore() (yymorfg=1)
  16. # define ECHO fprintf(yyout, "%s",yytext)
  17. # define REJECT { nstr = yyreject(); goto yyfussy;}
  18. int yyleng; extern char yytext[];
  19. int yymorfg;
  20. extern char *yysptr, yysbuf[];
  21. int yytchar;
  22. FILE *yyin = {stdin}, *yyout = {stdout};
  23. extern int yylineno;
  24. struct yysvf { 
  25.     struct yywork *yystoff;
  26.     struct yysvf *yyother;
  27.     int *yystops;};
  28. struct yysvf *yyestate;
  29. extern struct yysvf yysvec[], *yybgin;
  30. /************************************************************************
  31.  *                                    *
  32.  *            Copyright (c) 1982, Fred Fish            *
  33.  *                All Rights Reserved                *
  34.  *                                    *
  35.  *    This software and/or documentation is released for public    *
  36.  *    distribution for personal, non-commercial use only.        *
  37.  *    Limited rights to use, modify, and redistribute are hereby    *
  38.  *    granted for non-commercial purposes, provided that all        *
  39.  *    copyright notices remain intact and all changes are clearly    *
  40.  *    documented.  The author makes no warranty of any kind with    *
  41.  *    respect to this product and explicitly disclaims any implied    *
  42.  *    warranties of merchantability or fitness for any particular    *
  43.  *    purpose.                            *
  44.  *                                    *
  45.  ************************************************************************
  46.  */
  47.  
  48.  
  49. /*
  50.  *  FILE
  51.  *
  52.  *    dex.l   lex specification for documentation extraction utility
  53.  *
  54.  *  KEY WORDS
  55.  *
  56.  *    lex specification
  57.  *    dex
  58.  *
  59.  *  SYNOPSIS
  60.  *
  61.  *    lex dex.l
  62.  *    mv lex.yy.c dex.lo
  63.  *
  64.  *  DESCRIPTION
  65.  *
  66.  *    This file contains the lex specification for the "dex"
  67.  *    documentation extraction utility.  It is used with the file
  68.  *    "dex.y", which is the yacc specification, to generate the
  69.  *    source file parser.
  70.  *
  71.  *  AUTHOR
  72.  *
  73.  *    Fred Fish
  74.  *
  75.  */
  76. # define DLINE 2
  77. # define YYNEWLINE 10
  78. yylex(){
  79. int nstr; extern int yyprevious;
  80. extern int debug;
  81. while((nstr = yylook()) >= 0)
  82. yyfussy: switch(nstr){
  83. case 0:
  84. if(yywrap()) return(0); break;
  85. case 1:
  86. {
  87.             BEGIN DLINE;
  88.             if (debug) {printf("yylex: HSTART \"%s\"\n",yytext);}
  89.             return(HSTART);
  90.         }
  91. break;
  92. case 2:
  93. {
  94.             BEGIN DLINE;
  95.             if (debug) {printf("yylex: FSTART \"%s\"\n",yytext);}
  96.             return(FSTART);
  97.         }
  98. break;
  99. case 3:
  100. {
  101.             BEGIN DLINE;
  102.             if (debug) {printf("yylex: UFSTART \"%s\"\n",yytext);}
  103.             return(UFSTART);
  104.         }
  105. break;
  106. case 4:
  107. {
  108.             BEGIN 0;
  109.             if (debug) {printf("yylex: BSTART \"%s\"\n",yytext);}
  110.             return(BSTART);
  111.         }
  112. break;
  113. case 5:
  114. {
  115.             if (debug) {printf("yylex: TEXT \"%s\"\n",yytext);}
  116.             return(TEXT);
  117.         }
  118. break;
  119. case 6:
  120.     {
  121.             BEGIN 0;
  122.             if (debug) {printf("yylex: NEWLINE \"%s\"\n",yytext);}
  123.             return(NEWLINE);
  124.         }
  125. break;
  126. case 7:
  127. {
  128.             BEGIN 0;
  129.             if (debug) {printf("yylex: JUNK1 \"%s\"\n",yytext);}
  130.             return(JUNK);
  131.         }
  132. break;
  133. case 8:
  134. {
  135.             BEGIN 0;
  136.             if (debug) {printf("yylex: JUNK2 \"%s\"\n",yytext);}
  137.             return(JUNK);
  138.         }
  139. break;
  140. case 9:
  141. {
  142.             BEGIN 0;
  143.             if (debug) {printf("yylex: JUNK3 \"%s\"\n",yytext);}
  144.             return(JUNK);
  145.         }
  146. break;
  147. case 10:
  148. {
  149.             BEGIN 0;
  150.             if (debug) {printf("yylex: JUNK4 \"%s\"\n",yytext);}
  151.             return(JUNK);
  152.         }
  153. break;
  154. case -1:
  155. break;
  156. default:
  157. fprintf(yyout,"bad switch yylook %d",nstr);
  158. } return(0); }
  159. /* end of yylex */
  160. extern FILE *infp;
  161.  
  162. #undef input            /* Make preprocessor forget macro */
  163. input()
  164. {
  165.     char ch;
  166.  
  167.     ch = fgetc(infp);
  168.     switch(ch) {
  169.     case EOF:
  170.     ch = NULL;
  171.     break;
  172.     case NULL:
  173.     ch = '\n';
  174.         break;
  175.     }
  176.     ch &= '\177';
  177.     return(ch);
  178. }
  179.  
  180. #undef unput            /* Make preprocessor forget macro */
  181. unput(ch)
  182. char ch;
  183. {
  184.     if (ch == NULL) {
  185.     ch = EOF;
  186.     }
  187.     ungetc(ch,infp);
  188. }
  189. int yyvstop[] = {
  190. 0,
  191.  
  192. 5,
  193. 0,
  194.  
  195. 5,
  196. 0,
  197.  
  198. 5,
  199. 0,
  200.  
  201. 5,
  202. 0,
  203.  
  204. 10,
  205. 0,
  206.  
  207. 6,
  208. 10,
  209. 0,
  210.  
  211. 10,
  212. 11,
  213. 0,
  214.  
  215. 8,
  216. 10,
  217. 0,
  218.  
  219. 10,
  220. -7,
  221. 0,
  222.  
  223. 8,
  224. 10,
  225. 11,
  226. 0,
  227.  
  228. 10,
  229. -4,
  230. 0,
  231.  
  232. 5,
  233. 10,
  234. 0,
  235.  
  236. 5,
  237. 10,
  238. 11,
  239. 0,
  240.  
  241. 5,
  242. 8,
  243. 10,
  244. 0,
  245.  
  246. 5,
  247. 10,
  248. -7,
  249. 0,
  250.  
  251. 5,
  252. 8,
  253. 10,
  254. 11,
  255. 0,
  256.  
  257. 5,
  258. 10,
  259. -4,
  260. 0,
  261.  
  262. 8,
  263. 0,
  264.  
  265. -7,
  266. 0,
  267.  
  268. 7,
  269. 0,
  270.  
  271. -4,
  272. 0,
  273.  
  274. 9,
  275. 0,
  276.  
  277. 2,
  278. -4,
  279. 0,
  280.  
  281. 4,
  282. 0,
  283.  
  284. -4,
  285. 0,
  286.  
  287. 5,
  288. 0,
  289.  
  290. 5,
  291. 8,
  292. 0,
  293.  
  294. 5,
  295. -7,
  296. 0,
  297.  
  298. 5,
  299. -4,
  300. 0,
  301.  
  302. 5,
  303. 9,
  304. 0,
  305.  
  306. 2,
  307. 5,
  308. -4,
  309. 0,
  310.  
  311. 5,
  312. -4,
  313. 0,
  314.  
  315. 3,
  316. -4,
  317. 0,
  318.  
  319. -4,
  320. 0,
  321.  
  322. 1,
  323. -4,
  324. 0,
  325.  
  326. 3,
  327. 5,
  328. -4,
  329. 0,
  330.  
  331. 5,
  332. -4,
  333. 0,
  334.  
  335. 1,
  336. 5,
  337. -4,
  338. 0,
  339. 0};
  340. # define YYTYPE char
  341. struct yywork { YYTYPE verify, advance; } yycrank[] = {
  342. 0,0,    0,0,    1,5,    0,0,    
  343. 2,8,    0,0,    3,12,    0,0,    
  344. 4,14,    0,0,    1,5,    1,6,    
  345. 2,9,    1,7,    3,12,    2,10,    
  346. 4,15,    3,13,    8,18,    4,16,    
  347. 9,19,    9,20,    10,0,    11,22,    
  348. 13,0,    12,26,    8,18,    8,0,    
  349. 16,0,    15,28,    15,20,    11,23,    
  350. 11,24,    12,26,    12,0,    14,27,    
  351. 1,5,    17,30,    2,11,    18,0,    
  352. 3,12,    21,25,    4,17,    14,27,    
  353. 14,0,    17,31,    9,21,    19,19,    
  354. 19,20,    23,33,    23,24,    25,34,    
  355. 8,18,    22,22,    11,25,    15,29,    
  356. 26,0,    11,22,    27,0,    12,26,    
  357. 33,34,    22,22,    22,0,    28,28,    
  358. 28,20,    31,36,    31,24,    29,30,    
  359. 17,32,    14,27,    30,30,    17,30,    
  360. 23,34,    19,21,    25,35,    29,31,    
  361. 32,37,    32,24,    30,30,    30,0,    
  362. 34,34,    0,0,    35,34,    36,37,    
  363. 36,24,    37,37,    37,24,    22,22,    
  364. 31,37,    28,29,    38,37,    38,24,    
  365. 0,0,    0,0,    0,0,    0,0,    
  366. 0,0,    0,0,    29,32,    32,38,    
  367. 0,0,    29,30,    0,0,    0,0,    
  368. 30,30,    35,35,    0,0,    0,0,    
  369. 0,0,    0,0,    0,0,    0,0,    
  370. 0,0,    38,38,    0,0,    0,0,    
  371. 0,0};
  372. struct yysvf yysvec[] = {
  373. 0,    0,    0,
  374. yycrank+-1,    0,        yyvstop+1,
  375. yycrank+-3,    yysvec+1,    yyvstop+3,
  376. yycrank+-5,    yysvec+1,    yyvstop+5,
  377. yycrank+-7,    yysvec+1,    yyvstop+7,
  378. yycrank+0,    0,        yyvstop+9,
  379. yycrank+0,    0,        yyvstop+11,
  380. yycrank+0,    0,        yyvstop+14,
  381. yycrank+-17,    0,        yyvstop+17,
  382. yycrank+-11,    yysvec+8,    yyvstop+20,
  383. yycrank+-12,    yysvec+8,    yyvstop+23,
  384. yycrank+-22,    0,        yyvstop+27,
  385. yycrank+-24,    0,        yyvstop+30,
  386. yycrank+-14,    yysvec+12,    yyvstop+33,
  387. yycrank+-34,    0,        yyvstop+37,
  388. yycrank+-20,    yysvec+14,    yyvstop+41,
  389. yycrank+-18,    yysvec+14,    yyvstop+45,
  390. yycrank+-36,    yysvec+11,    yyvstop+50,
  391. yycrank+-29,    yysvec+8,    yyvstop+54,
  392. yycrank+-38,    yysvec+8,    yyvstop+56,
  393. yycrank+0,    0,        yyvstop+58,
  394. yycrank+-9,    yysvec+11,    yyvstop+60,
  395. yycrank+-52,    0,        yyvstop+62,
  396. yycrank+40,    0,        yyvstop+64,
  397. yycrank+0,    0,        yyvstop+67,
  398. yycrank+42,    yysvec+23,    yyvstop+69,
  399. yycrank+-46,    yysvec+12,    yyvstop+71,
  400. yycrank+-48,    yysvec+14,    yyvstop+73,
  401. yycrank+-54,    yysvec+14,    yyvstop+76,
  402. yycrank+-66,    yysvec+11,    yyvstop+79,
  403. yycrank+-69,    0,        yyvstop+82,
  404. yycrank+-56,    yysvec+12,    yyvstop+85,
  405. yycrank+-67,    yysvec+12,    yyvstop+89,
  406. yycrank+51,    yysvec+23,    yyvstop+92,
  407. yycrank+71,    yysvec+23,    yyvstop+95,
  408. yycrank+73,    yysvec+23,    yyvstop+97,
  409. yycrank+-74,    yysvec+12,    yyvstop+100,
  410. yycrank+-76,    yysvec+12,    yyvstop+104,
  411. yycrank+-81,    yysvec+12,    yyvstop+107,
  412. 0,    0,    0};
  413. struct yywork *yytop = yycrank+113;
  414. struct yysvf *yybgin = yysvec+1;
  415. char yymatch[] = {
  416. 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  417. 01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,
  418. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  419. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  420. 011 ,01  ,01  ,'#' ,01  ,01  ,01  ,01  ,
  421. 01  ,01  ,'#' ,01  ,01  ,01  ,01  ,01  ,
  422. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  423. 01  ,01  ,01  ,'#' ,01  ,01  ,01  ,01  ,
  424. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  425. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  426. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  427. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  428. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  429. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  430. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  431. 01  ,01  ,01  ,01  ,'#' ,01  ,01  ,01  ,
  432. 0};
  433. char yyextra[] = {
  434. 0,0,0,0,1,0,0,1,
  435. 0,0,0,0,0,0,0,0,
  436. 0};
  437. /*    @(#)ncform    1.2    */
  438. int yylineno =1;
  439. # define YYU(x) x
  440. # define NLSTATE yyprevious=YYNEWLINE
  441. char yytext[YYLMAX];
  442. struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
  443. char yysbuf[YYLMAX];
  444. char *yysptr = yysbuf;
  445. int *yyfnd;
  446. extern struct yysvf *yyestate;
  447. int yyprevious = YYNEWLINE;
  448. yylook(){
  449.     register struct yysvf *yystate, **lsp;
  450.     register struct yywork *yyt;
  451.     struct yysvf *yyz;
  452.     int yych, yyfirst;
  453.     struct yywork *yyr;
  454. # ifdef LEXDEBUG
  455.     int debug;
  456. # endif
  457.     char *yylastch;
  458.     /* start off machines */
  459. # ifdef LEXDEBUG
  460.     debug = 0;
  461. # endif
  462.     yyfirst=1;
  463.     if (!yymorfg)
  464.         yylastch = yytext;
  465.     else {
  466.         yymorfg=0;
  467.         yylastch = yytext+yyleng;
  468.         }
  469.     for(;;){
  470.         lsp = yylstate;
  471.         yyestate = yystate = yybgin;
  472.         if (yyprevious==YYNEWLINE) yystate++;
  473.         for (;;){
  474. # ifdef LEXDEBUG
  475.             if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
  476. # endif
  477.             yyt = yystate->yystoff;
  478.             if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
  479.                 yyz = yystate->yyother;
  480.                 if(yyz == 0)break;
  481.                 if(yyz->yystoff == yycrank)break;
  482.                 }
  483.             *yylastch++ = yych = input();
  484.             yyfirst=0;
  485.         tryagain:
  486. # ifdef LEXDEBUG
  487.             if(debug){
  488.                 fprintf(yyout,"char ");
  489.                 allprint(yych);
  490.                 putchar('\n');
  491.                 }
  492. # endif
  493.             yyr = yyt;
  494.             if ( (int)yyt > (int)yycrank){
  495.                 yyt = yyr + yych;
  496.                 if (yyt <= yytop && yyt->verify+yysvec == yystate){
  497.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  498.                         {unput(*--yylastch);break;}
  499.                     *lsp++ = yystate = yyt->advance+yysvec;
  500.                     goto contin;
  501.                     }
  502.                 }
  503. # ifdef YYOPTIM
  504.             else if((int)yyt < (int)yycrank) {        /* r < yycrank */
  505.                 yyt = yyr = yycrank+(yycrank-yyt);
  506. # ifdef LEXDEBUG
  507.                 if(debug)fprintf(yyout,"compressed state\n");
  508. # endif
  509.                 yyt = yyt + yych;
  510.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  511.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  512.                         {unput(*--yylastch);break;}
  513.                     *lsp++ = yystate = yyt->advance+yysvec;
  514.                     goto contin;
  515.                     }
  516.                 yyt = yyr + YYU(yymatch[yych]);
  517. # ifdef LEXDEBUG
  518.                 if(debug){
  519.                     fprintf(yyout,"try fall back character ");
  520.                     allprint(YYU(yymatch[yych]));
  521.                     putchar('\n');
  522.                     }
  523. # endif
  524.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  525.                     if(yyt->advance+yysvec == YYLERR)    /* error transition */
  526.                         {unput(*--yylastch);break;}
  527.                     *lsp++ = yystate = yyt->advance+yysvec;
  528.                     goto contin;
  529.                     }
  530.                 }
  531.             if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
  532. # ifdef LEXDEBUG
  533.                 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
  534. # endif
  535.                 goto tryagain;
  536.                 }
  537. # endif
  538.             else
  539.                 {unput(*--yylastch);break;}
  540.         contin:
  541. # ifdef LEXDEBUG
  542.             if(debug){
  543.                 fprintf(yyout,"state %d char ",yystate-yysvec-1);
  544.                 allprint(yych);
  545.                 putchar('\n');
  546.                 }
  547. # endif
  548.             ;
  549.             }
  550. # ifdef LEXDEBUG
  551.         if(debug){
  552.             fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
  553.             allprint(yych);
  554.             putchar('\n');
  555.             }
  556. # endif
  557.         while (lsp-- > yylstate){
  558.             *yylastch-- = 0;
  559.             if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
  560.                 yyolsp = lsp;
  561.                 if(yyextra[*yyfnd]){        /* must backup */
  562.                     while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
  563.                         lsp--;
  564.                         unput(*yylastch--);
  565.                         }
  566.                     }
  567.                 yyprevious = YYU(*yylastch);
  568.                 yylsp = lsp;
  569.                 yyleng = yylastch-yytext+1;
  570.                 yytext[yyleng] = 0;
  571. # ifdef LEXDEBUG
  572.                 if(debug){
  573.                     fprintf(yyout,"\nmatch ");
  574.                     sprint(yytext);
  575.                     fprintf(yyout," action %d\n",*yyfnd);
  576.                     }
  577. # endif
  578.                 return(*yyfnd++);
  579.                 }
  580.             unput(*yylastch);
  581.             }
  582.         if (yytext[0] == 0  /* && feof(yyin) */)
  583.             {
  584.             yysptr=yysbuf;
  585.             return(0);
  586.             }
  587.         yyprevious = yytext[0] = input();
  588.         if (yyprevious>0)
  589.             output(yyprevious);
  590.         yylastch=yytext;
  591. # ifdef LEXDEBUG
  592.         if(debug)putchar('\n');
  593. # endif
  594.         }
  595.     }
  596. yyback(p, m)
  597.     int *p;
  598. {
  599. if (p==0) return(0);
  600. while (*p)
  601.     {
  602.     if (*p++ == m)
  603.         return(1);
  604.     }
  605. return(0);
  606. }
  607.     /* the following are only used in the lex library */
  608. yyinput(){
  609.     return(input());
  610.     }
  611. yyoutput(c)
  612.   int c; {
  613.     output(c);
  614.     }
  615. yyunput(c)
  616.    int c; {
  617.     unput(c);
  618.     }
  619.